/**
 * ================================
 *              ReadMe
 * 1. 默认的http api后续您应该根据页面进行区分
 * 2. 本文件即作为一个示例
 * 3. 首先我们需要将axios导入
 * 4. 编写完逻辑后将api导出到../api.js中进行统一管理
 *
 * ================================
 */
import axios from '@/request/axios'

/**
 * post 方法
 * @param {*} params
 * @param config
 * @returns
 */
export const login = async (config = {}) => {
  console.log("🚀 ~ file: defaultApi.js:20 ~ login ~ config:", config)
  const { data: res } = await axios.get('/api/login', {
    params:config.params,
    loading:  config.loading || false,
    showMessage: config.loading || false
  })
  return res
}
export const uploadFile = async (config = {}) => {
  console.log("🚀 ~ file: defaultApi.js:20 ~ login ~ config:", config)
  const { data: res } = await axios.get('api/uploadFile', {
    params:config.params,
    loading:  config.loading || false,
    showMessage: config.loading || false
  })
  return res
}
export const getUser = async (config = {}) => {
  const { data: res } = await axios.get('/auth/getUser', {
    params:config.params,
    loading:  config.loading || false,
    showMessage: config.loading || false
  })
  return res
}
export const addUser = async (config = {}) => {
  const { data: res } = await axios.post(`/auth/addUser?username=${config.params.username}&contact=${config.params.contact}&job_number=${config.params.job_number}&price_table=${config.params.price_table}&remark=${config.params.remark}`, {
    // params:config.params,
    loading:  config.loading || false,
    showMessage: config.loading || false
  })
  return res
}
export const updateUser = async (config = {}) => {
  const { data: res } = await axios.post(`/auth/updateUser?username=${config.params.username}&contact=${config.params.contact}&job_number=${config.params.job_number}&price_table=${config.params.price_table}&remark=${config.params.remark}&id=${config.params.id}`, {
    // params:config.params,
    loading:  config.loading || false,
    showMessage: config.loading || false
  })
  return res
}
export const delUser = async (config = {}) => {
  const { data: res } = await axios.delete(`/auth/deleteUser?id=${config.id}`, {
    loading:  config.loading || false,
    showMessage: config.loading || false
  })
  return res
}

